<?
	session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title><?php echo $GuildName;?> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="DKP WOW GUILD">
<meta name="Description" content="">
<link href="<?php echo $StylePath;?>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<?php echo $StylePath;?>/styleplus.js"></script>
<style type="text/css" media="all">

</style>
</head>

<body>
<div class="main">
<?php 
if (${"action"}=="add") {

eventadd();
}
	else
if (${"action"}=="edit") {

eventedit();
}
	else
if (${"action"}=="del") {

eventdel(${"id"});
} 

function eventadd() {
	extract($GLOBALS);

//验证提交数据有效性
	if (!is_numeric(${"postid"})) {
		$errorinfo=$errorinfo."<li>内部参数错误</li>";
	} 
	if (!$IsDate[${"event_date"}." ".${"event_time"}]) {
		$errorinfo=$errorinfo."<li>时间格式不正确,请参考旁边的格式</li>";
	} 
	if (${"event_class"}=="加入" || ${"event_class"}=="离开" || ${"event_class"}=="拾取") {

		if (${"object"}=="") {
			$errorinfo=$errorinfo."<li>请选择事件人员</li>";
		} 
	}
		else
	if (${"event_class"}=="分解") {

		if (${"object2"}=="") {
			$errorinfo=$errorinfo."<li>请注明事件的物品名称</li>";
		} 
	}
		else
	if (${"event_class"}=="发现" || ${"event_class"}=="首次" || ${"event_class"}=="击杀") {

		if (${"object2"}=="") {
			$errorinfo=$errorinfo."<li>请注明事件的对象名称</li>";
		} 
	}
		else
	{

		if (${"object2"}=="") {
			$errorinfo=$errorinfo."<li>请填写事件的解释信息</li>";
		} 
		if (!is_numeric(${"event_dkp"})) {
			$errorinfo=$errorinfo."<li>请填写事件所得DKP</li>";
		} 
	} 

//验证///

	if ($errorinfo!="") {

//抛出错误提示
		print "<div class='message'><h3>表单信息有误,提示如下:</h3><div><ul>".$errorinfo."</ul>";
		print "<a href='".$Url."' class='abtn'>返回修改</a></div></div>";
	}
		else
	{

//写入数据库
		$sql="Select * from raid_event where (id is null)";
		$result = mysql_query($sql);$sql    $conn
		$result->addnew;
		$result["event_raidid"]=${"postid"};
		$result["event_time"]=$Cdate[${"event_date"}." ".${"event_time"}];
		$result["event_class"]=${"event_class"};
		if (${"event_class"}=="分解" || ${"event_class"}=="仓库" || ${"event_class"}=="发现" || ${"event_class"}=="首次" || ${"event_class"}=="击杀" || ${"event_class"}=="团队事件" || ${"event_class"}=="活动事件") {

			$result["event_object"]="-";
		}
			else
		{

			$result["event_object"]=trim(${"object"});
		} 

		if ((strpos(${"object"},"|") ? strpos(${"object"},"|")+1 : 0) && substr(${"object"},0,1)!="|") {

			$result["event_object"]="|".$result["event_object"];
		} 

		if ((strpos(${"object"},"|") ? strpos(${"object"},"|")+1 : 0) && substr(${"object"},strlen(${"object"})-(1))!="|") {

			$result["event_object"]=$result["event_object"]."|";
		} 

		$result["event_object2"]=trim(${"object2"});
		$result["raid_class"]=${"class_name"};
		if (${"event_class"}=="加入" || ${"event_class"}=="离开" || ${"event_class"}=="发现" || ${"event_class"}=="首次" || ${"event_dkp"}=="") {

			$result["event_dkp"]=0;
		}
			else
		{

			$result["event_dkp"]=${"event_dkp"};
			$result["event_dkp2"]=${"event_dkp2"};
		} 

		$result->update;
		$result->close;
		header("Location: ".$Url);
	} 

	return $function_ret;
} 


function eventdel($id) {
	extract($GLOBALS);

	if (!is_numeric(${"postid"})) {
		return $function_ret;

	} 
	$sql="delete 1 from raid_event where id=".${"id"};
	$conn->execute($sql);
	header("Location: ".$Url);
	return $function_ret;
} 


function eventedit() {
	extract($GLOBALS);

//验证提交数据有效性
	if (!is_numeric(${"postid"})) {
		$errorinfo=$errorinfo."<li>内部参数错误</li>";
	} 
	if (!$IsDate[${"event_date"}." ".${"event_time"}]) {
		$errorinfo=$errorinfo."<li>时间格式不正确,请参考旁边的格式</li>";
	} 
	if (${"event_class"}=="加入" || ${"event_class"}=="离开" || ${"event_class"}=="拾取") {

		if (${"object"}=="") {
			$errorinfo=$errorinfo."<li>请选择事件人员</li>";
		} 
	}
		else
	if (${"event_class"}=="分解") {

		if (${"object2"}=="") {
			$errorinfo=$errorinfo."<li>请注明事件的物品名称</li>";
		} 
	}
		else
	if (${"event_class"}=="发现" || ${"event_class"}=="首次" || ${"event_class"}=="击杀") {

		if (${"object2"}=="") {
			$errorinfo=$errorinfo."<li>请注明事件的对象名称</li>";
		} 
	}
		else
	{

		if (${"object2"}=="") {
			$errorinfo=$errorinfo."<li>请填写事件的解释信息</li>";
		} 
		if (!is_numeric(${"event_dkp"})) {
			$errorinfo=$errorinfo."<li>请填写事件所得DKP</li>";
		} 
	} 

//验证///

	if ($errorinfo!="") {

//抛出错误提示
		print "<div class='message'><h3>表单信息有误,提示如下:</h3><div><ul>".$errorinfo."</ul>";
		print "<a href='".$Url."' class='abtn'>返回修改</a></div></div>";
	}
		else
	{

//写入数据库
		$sql="Select * from raid_event where id=".${"postid"};
		$result = mysql_query($sql);$sql    $conn
		$result["event_raidid"]=${"rid"};
		$result["event_time"]=$Cdate[${"event_date"}." ".${"event_time"}];
		$result["event_class"]=${"event_class"};
		if (${"event_class"}=="分解" || ${"event_class"}=="仓库" || ${"event_class"}=="发现" || ${"event_class"}=="首次" || ${"event_class"}=="击杀" || ${"event_class"}=="团队事件" || ${"event_class"}=="活动事件") {

			$result["event_object"]="-";
		}
			else
		{

			$result["event_object"]=trim(${"object"});
		} 


		if ((strpos(${"object"},"|") ? strpos(${"object"},"|")+1 : 0) && substr(${"object"},0,1)!="|") {

			$result["event_object"]="|".$result["event_object"];
		} 

		if ((strpos(${"object"},"|") ? strpos(${"object"},"|")+1 : 0) && substr(${"object"},strlen(${"object"})-(1))!="|") {

			$result["event_object"]=$result["event_object"]."|";
		} 

		$result["event_object2"]=trim(${"object2"});
		$result["raid_class"]=${"class_name"};
		if (${"event_class"}=="加入" || ${"event_class"}=="离开" || ${"event_class"}=="发现" || ${"event_class"}=="首次") {

			$result["event_dkp"]=0;
		}
			else
		{

			$result["event_dkp"]=${"event_dkp"};
		} 

		$result["event_dkp2"]=${"event_dkp2"};
		$result->update;
		$result->close;
		header("Location: "."admin_report.php?action=collect2&id=".${"rid"});
	} 

	return $function_ret;
} 
?>
</div>
</body>
</html>
